<template>
  <ul class="videoALL">
    <li class="videoList" v-for="(h, index) in col.content" :key="h.id">
      <div class="video">
        <img class="videoInfo" :src="h.momentBackup.cover"  />
        <div class="videoMessage">
          <!-- 之后需要绑定点击事件跳转到视频页 -->
          <div>{{h.momentTitle}}</div>
          <span class="housework">视频课</span>
          <div class="avatar">
            <img :src="h.momentBackup.creatorBackup.avatar" />
            <!-- 点击跳转到个人主页 -->
            <span>{{h.momentBackup.creatorBackup.name }}</span>
          </div>
        </div>
      </div>
      <div class="time">{{ calcTime(h.createTime) }}</div>
      <!-- 删除按钮 -->
      <el-button class="deleteOne" text @click="centerDialogVisible = true"
        >删除</el-button
      >
      <el-dialog
        v-model="centerDialogVisible"
        title="提示"
        width="30%"
        align-center
      >
        <span>此操作将删除该项, 是否继续?</span>
        <template #footer>
          <span class="dialog-footer">
            <el-button @click="centerDialogVisible = false">取消</el-button>
            <el-button type="primary" @click="one">确定</el-button>
          </span>
        </template>
      </el-dialog>
    </li>
  </ul>
  <div class="noContain" v-if="!col.content.length">
    <span>无更多数据</span>
  </div>
</template>

<script  lang="ts">
export default {
  name: "shoucang",
};
</script>
<script lang="ts" setup>
import { ref,onMounted } from "vue";
// 引入仓库
import useUserInfoStore from "../../../store/practive/index";

// 使用仓库
const col = useUserInfoStore();

onMounted(()=>{
  col.getCollect();
})

//计算时间
const calcTime = (time) => {
  if ((new Date().getTime() - time)> 6000000) {
    let hour = Math.floor((new Date().getTime() - time) / 1000 / 60 / 60);
    return hour + "小时";
  }

  let minutes = Math.floor((new Date().getTime() - time) / 1000 / 60);
  return minutes + "分钟";
  // moment(time).startOf('hour').fromNow();
};
// 列表里删除插件
const centerDialogVisible = ref(false);
</script>

<style scoped>
.videoALL {
  margin: 0 auto;
  
}
.videoList {
  width: 963px;
  height: 121px;
  margin: 10px 0;
  display: flex;
  margin: 0 auto;
}
.videoList:hover {
  background-color: #f5f7fa;
}
.video {
  width: 680px;
  height: 121px;
  display: flex;
}
.video .videoInfo {
  width: 169px;
  height: 101px;
  margin: 10px 10px;
  border-radius: 5px;
}
.video .videoMessage {
  margin: 10px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.video .videoMessage .housework {
  color: rgb(125, 128, 144);
  font-size: 12px;
}
.video .videoMessage img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  vertical-align: text-top;
  margin-right: 10px;
}
.time {
  width: 153px;
  height: 121px;
  line-height: 121px;
  text-align: center;
  font-size: 14px;
  margin-left: 100px;
}
.deleteOne {
  width: 145px;
  height: 121px;
  line-height: 121px;
  text-align: right;
  font-size: 14px;
  color: #b1b3bc;
  margin-right: 5px;
}
.deleteOne:hover {
  color: #f93684;
  cursor: pointer;
}

.noContain {
  text-align: center;
  height: 80px;
  line-height: 80px;
  border-bottom: solid 1px #606266;
  color: #606266;
}
/* 删除按钮插件 */
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>